import 'package:get/get.dart';
import 'package:safetymonitor/app/core/http/http.dart';
import 'package:safetymonitor/app/core/utils/interface.dart';
import 'package:safetymonitor/app/data/entities/application/get_statistice_score_entity.dart';

class IndexRatingController extends GetxController {
  bool isNotPermissions=true;
  /// 获取数据
  Future<List<GetStatisticeScoreEntity>> getStatisticsScore(
      int index, int size,
      {String? search}) async {
    final res = await HttpUtil()
        .generateGetRequest<List<GetStatisticeScoreEntity>>(
            Interface.getStatisticsScore,
            queryParameters: {
          'latest': true,
          'pageNo': index,
          'pageSize': size,
        }).execute();
    List<GetStatisticeScoreEntity>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
      }
      isNotPermissions=true;
      update();
    });
    res.onError((result) {
      if(result.code==403&&result.message=='没有该操作权限'){
        isNotPermissions=false;
        update();
      }
    });
    return list ?? [];
  }
}
